<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>

        <ui:composition template="../templates/default3.xhtml">  

            <ui:define name="content">

                <h:form binding="#{salesOrderManagerBean.loadSalesOrdersPage}">
                    <p:panel header="Sales Orders" id="salesOrdersPanel">
                        <p:messages />
                        <h:outputText id="output" value="There are currently #{salesOrderManagerBean.salesOrdersSize} sales orders pending approval." />
                        <hr />
                        <p:dataTable id="salesOrders" var="salesOrder" value="#{salesOrderManagerBean.salesOrders}" paginator="true" 
                                     selectionMode="single" selection="#{salesOrderManagerBean.selectedSalesOrder}"
                                     emptyMessage="No sales orders found with given criteria."
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} 
                                     {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                     rowsPerPageTemplate="5,10,15" rows="10" 
                                     rowSelectListener="#{salesOrderManagerBean.onRowSelect}"
                                     rowUnselectListener="#{salesOrderManagerBean.onRowUnselect}">
                            <p:column filterBy="#{salesOrder.job.customer.company}" headerText="Customer" filterMatchMode="contains">  
                                <h:outputText value="#{salesOrder.job.customer.company}" />  
                            </p:column> 
                            <p:column filterBy="#{salesOrder.job.employee.userId}" headerText="Sales Executive" filterMatchMode="contains">  
                                <h:outputText value="#{salesOrder.job.employee.userId}" />  
                            </p:column> 
                            <p:column filterBy="#{salesOrder.creditCheck}" headerText="Credit Check" filterMatchMode="contains">  
                                <h:outputText value="#{salesOrder.creditCheck}" />  
                            </p:column> 
                            <p:column filterBy="#{salesOrder.atpCheck}" headerText="ATP Check" filterMatchMode="contains">  
                                <h:outputText value="#{salesOrder.atpCheck}" />  
                            </p:column> 
                            <p:column headerText="Creation Date"> 
                                <h:outputText value="#{salesOrder.creationDate}">  
                                    <f:convertDateTime pattern="dd-MM-yyyy hh:mm a" timeZone="#{defaultManagerBean.tz}"/>
                                </h:outputText>
                            </p:column>
                        </p:dataTable>
                        <hr/>
                        <table width="100%" border="0">
                            <tr>
                                <td class="btn">
                                    <p:commandButton value="View Sales Order" update="salesOrdersPanel" id="viewSalesOrder" 
                                                     actionListener="#{salesOrderManagerBean.viewSalesOrder}"/>
                                </td>
                            </tr>
                        </table>

                    </p:panel>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
